<!DOCTYPE html>
<html lang="en">
<head>
    <title>编辑</title>
    <link rel="stylesheet" href="${ctxPath!}/js/extend/formSelect/formSelects-v4.css"/>
    <%include("/WEB-INF/views/common/basejs.html"){}%>
    <script>
        //全局定义一次, 加载formSelects
        //当前用户部门ID
        var deptId="${user.deptId!}";
        layui.config({
            base: '../js/extend/formSelect/' //此处路径请自行处理, 可以使用绝对路径
        }).extend({
            formSelects:'formSelects-v4'
        }).use(['form','layer','jquery','formSelects','laydate'],function(){
            var form = layui.form
                ,layer = layui.layer,
                $=layui.jquery,
                formSelects=layui.formSelects,
                layDate=layui.laydate;
            //初始化组织结构下拉树
            formSelects.data('deptId','server',{
                url:basePath+'/dept/showDeptTree',
                success:function(){
                    if(deptId){
                        //设置默认值
                        formSelects.value('deptId', [${user.deptId!}]);
                    }
                }
            });
            //初始化日期控件
            layDate.render({
                elem: '#eidtBirthdate',
                value: '${user.birthdate!}'
            });
            //提交form监听表单
            form.on('submit(update)',function(data){
                //console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
                $.ajax({
                    url:basePath+'/user/update',
                    type:'post',
                    data:data.field,
                    dataType:'json',
                    success:function(data){
                        if(data.code==0){
                            //更新父元素的表格
                            window.parent.query();
                            //添加成功之后关闭当前窗口
                        }
                        window.parent.closeEditPage();
                        window.parent.layer.msg(data.msg);
                    },
                    error:function(){

                    }
                });
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });
        });
    </script>
</head>
<body>
<form class="layui-form layui-form-pane" action="" style="width:96%;margin:10px auto">
    <!--id隐藏-->
    <input name="id" value="${user.id!}" type="hidden">

    <!--开始-->
    <!--登录名-->
    <div class="layui-form-item">
        <label class="layui-form-label">登录名</label>
        <div class="layui-input-block">
            <input name="username" value="${user.username!}" type="text" lay-verify="required" disabled   autocomplete="off" placeholder="请输入登录名" class="layui-input">
        </div>
    </div>
    <!--密码-->
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">密码</label>-->
        <!--<div class="layui-input-block">-->
            <!--<input name="password" type="password" lay-verify="required" autocomplete="off" placeholder="请输入密码" class="layui-input">-->
        <!--</div>-->
    <!--</div>-->
    <!--所属部门-->
    <div class="layui-form-item">
        <label class="layui-form-label">所属部门</label>
        <div class="layui-input-block">
            <select name="deptId" xm-select="deptId" xm-select-radio xm-select-search >
                <option value="">请选择部门</option>
            </select>
        </div>
    </div>
    <!--真实姓名-->
    <div class="layui-form-item">
        <label class="layui-form-label">真实姓名</label>
        <div class="layui-input-block">
            <input name="realName" value="${user.realName!}" type="text" autocomplete="off" placeholder="请输入真实姓名" class="layui-input">
        </div>
    </div>
    <!--性别-->
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-block">
            <%
            if(user.sex==1){
            %>
            <input type="radio" name="sex" value="1" title="男" checked>
            <input type="radio" name="sex" value="0" title="女" >
            <%}
            else{
            %>
            <input type="radio" name="sex" value="1" title="男" >
            <input type="radio" name="sex" value="0" title="女" checked>
            <%}%>

        </div>
    </div>
    <!--生日-->
    <div class="layui-form-item">
        <label class="layui-form-label">生日</label>
        <div class="layui-input-block">
            <input id="eidtBirthdate" name="birthdate" type="text" autocomplete="off" placeholder="请输入生日" class="layui-input">
        </div>
    </div>
    <!--邮箱地址-->
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱地址</label>
        <div class="layui-input-block">
            <input name="email" value="${user.email!}" type="text"  autocomplete="off" placeholder="请输入邮箱地址" class="layui-input">
        </div>
    </div>
    <!--身份证号-->
    <div class="layui-form-item">
        <label class="layui-form-label">身份证号</label>
        <div class="layui-input-block">
            <input name="idCard" value="${user.idCard!}" type="text" autocomplete="off" placeholder="请输入身份证号" class="layui-input">
        </div>
    </div>
    <!--手机号-->
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-block">
            <input name="mobileNum" value="${user.mobileNum!}" type="text" autocomplete="off" placeholder="请输入手机号" class="layui-input">
        </div>
    </div>
    <!--状态-->
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <%
            if(user.status==1){
            %>
            <input type="radio" name="status" value="1" title="开启" checked>
            <input type="radio" name="status" value="2" title="禁用" >
            <%}
            else{
            %>
            <input type="radio" name="status" value="1" title="开启" >
            <input type="radio" name="status" value="2" title="禁用" checked>
            <%}%>
        </div>
    </div>
    <!--结束-->
    <div class="layui-form-item layui-hide">
        <button id="form-submit" class="layui-btn" lay-submit lay-filter="update">更新</button>
    </div>
</form>
</body>
</html>